<template>
  <div class="input-table">
    <div class="input-table-title" v-if="config.title">{{ config.title }}</div>
    <div class="input-table-inputs">
      <div class="input-table-input" v-for="(item, index) in config.values" :key="index">
        <label>{{ item.title }}</label>
        <el-input
          v-if="item.type === 'input'"
          v-model="value[item.dataIndex]"
          v-bind="item.props"
          placeholder="请输入"
        ></el-input>
        <el-select v-if="item.type === 'select'" v-model="value[item.dataIndex]" v-bind="item.props" placeholder="请选择">
          <el-option
            v-for="item in item.options"
            :key="item.code"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'InputTable',
  props: {
    config: {
      type: Object,
      default: () => {
        return {}
      }
    },
    value: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {}
  },
  created() {
  }
}
</script>
<style lang="scss" scoped>
.input-table {
  background: #fff;
  display: flex;
  width: 100%;
  padding: 14px 0;

  &-title {
    width: 220px;
    line-height: 36px;
    padding: 0 12px 0 0;
    font-size: 12px;
    font-weight: 500;
    text-align: right;
    word-break: keep-all;
  }

  &-inputs {
    display: flex;
    flex: 1;
    justify-content: space-around;
    border: 1px solid #dcdfe6;
    border-radius: 5px;
  }

  &-input {
    display: flex;
    flex: 1;
    flex-grow: 1; // 平均分配剩余空间
    border-left: 1px solid #dcdfe6;

    label {
      word-break: keep-all; // 让文字不换行
      font-size: 12px;
      font-weight: 500;
      color: #606266;
      //padding: 8px 20px 0 20px;
      text-align: center;
      width: 150px;
      line-height: 36px;
    }

    ::v-deep .el-input__inner {
      border: none;
      border-left: 1px solid #dcdfe6;
      border-radius: 0;
    }

    ::v-deep .el-input__inner:focus {
      border: none;
      border-left: 1px solid #dcdfe6;
      border-radius: 0;
    }

    //::v-deep .el-input__inner:nth-last-child(1) {
    //  border-top-right-radius: 5px;
    //  border-bottom-right-radius: 5px;
    //}
    ::v-deep .el-select {
      flex: 1;
    }
  }

  &-input:nth-child(1) {
    border-left: none;
  }
}
</style>
